function loadDataMagazine(page){                
             $.ajax
                    ({
                        type: "POST",
                        url: "../data/data_magazinee.php",
                        data: "page="+page,
                        success: function(msg)
                        {
                            $("#box_data_magazine").ajaxComplete(function(event, request, settings)
                            {
                                 $("#box_data_magazine").html(msg);
                                
                      });
                        
						}

                    });
                }

function loadDataFashion(page){                
             $.ajax
                    ({
                        type: "POST",
                        url: "../data/data_fashion.php",
                        data: "page="+page,
                        success: function(msg)
                        {
                            $("#box_data_fashion").ajaxComplete(function(event, request, settings)
                            {
                                 $("#box_data_fashion").html(msg);
                                
                      });
                        
						}

                    });
                }
function loadDataHealth(page){                
             $.ajax
                    ({
                        type: "POST",
                        url: "../data/data_health.php",
                        data: "page="+page,
                        success: function(msg)
                        {
                            $("#box_data_fashion").ajaxComplete(function(event, request, settings)
                            {
                                 $("#box_data_fashion").html(msg);
                                
                      });
                        
						}

                    });
                }
				
function paginationMagazine(){

            $('.pagination li.active').live('click',function(){
                    var page = $(this).attr('p');
                    loadDataMagazine(page);
                    
            });           
                
			$('#go_btn').live('click',function(){
                    var page = parseInt($('.goto').val());
                    var no_of_pages = parseInt($('.total').attr('a'));
                    if(page != 0 && page <= no_of_pages){
                        loadDataMagazine(page);
                    }else{
                        alert('กรุณาใส่ตัวเลขระหว่าง 1 ถึง '+no_of_pages);
                        $('.goto').val("").focus();
                        return false;
                    }
                    
          });
}
function paginationFashion(){

            $('.pagination li.active').live('click',function(){
                    var page = $(this).attr('p');
                    loadDataFashion(page);
                    
            });           
                
			$('#go_btn').live('click',function(){
                    var page = parseInt($('.goto').val());
                    var no_of_pages = parseInt($('.total').attr('a'));
                    if(page != 0 && page <= no_of_pages){
                        loadDataFashion(page);
                    }else{
                        alert('กรุณาใส่ตัวเลขระหว่าง 1 ถึง '+no_of_pages);
                        $('.goto').val("").focus();
                        return false;
                    }
                    
          });
}
function paginationHealth(){

            $('.pagination li.active').live('click',function(){
                    var page = $(this).attr('p');
                    loadDataHealth(page);
                    
            });           
                
			$('#go_btn').live('click',function(){
                    var page = parseInt($('.goto').val());
                    var no_of_pages = parseInt($('.total').attr('a'));
                    if(page != 0 && page <= no_of_pages){
                        loadDataHealth(page);
                    }else{
                        alert('กรุณาใส่ตัวเลขระหว่าง 1 ถึง '+no_of_pages);
                        $('.goto').val("").focus();
                        return false;
                    }
                    
          });
}

function top_nenw(){
$.ajax({
		url: '../data/top_new.php',
		type: 'GET',
		dataType: 'json',
		success: function(data) {
	//show data head

	 var temp_datanew ='';
     $.each(data["d_new"],function(i,v){
		 if(i > 2){

          temp_datanew+='<div class="data_new"><span class="img_new"><img src="/images/female1.png"></span/>'+
'<span class="news_top"><a href="/detail_article.php?c_id='+v['c_id']+'" target="_blank" title="'+v['c_title']+'">'+v['c_title']+'</a></span></div>';
		 }else{
		  temp_datanew+='<div class="data_new"><span class="img_new"><img src="/images/female1.png"></span/>'+
'<span class="news_top"><a href="/detail_news.php?c_id='+v['c_id']+'" target="_blank" title="'+v['c_title']+'">'+v['c_title']+'</a></span></div>';


		 }
	 
      
	});
	$("#update_new").html(temp_datanew);
  setInterval(function(){ 
				var n = $(".data_new").length;
				var fdivw = $('.data_new:first').width() + 25;
				$(".data_new:first").animate({"margin-left": "-="+fdivw+"px"}, "slow");
			setTimeout(function(){
					$(".data_new:first").remove();
				}, 3000);
				if(n < 3){
						$("#update_new").append(temp_datanew); 
					}
},5000);
		

 }



});
}

function magazine(){
$.ajax({
		url: '../data/data_magazine.php',
		type: 'POST',
		dataType: 'json',
		success: function(data) {
		
		$('#box_data_magazine').html(data["data_magazine"]);
		}
	});



}
function sweety(){

$.ajax({

		url: '../data/data_woman.php',
		type: 'POST',
		dataType: 'json',
		success: function(data) {
		if(data["sweety"] > 0){
		   $.each(data["d_s"],function(i,v){
		$('#data_sweety_girls').append('<div class="image_sweety"><a href="/detail_article.php?c_id='+v['c_id']+'" target="_blank" title="'+v['c_title']+'">'+v['c_image']+'</a></div>');
		   });
		}
	}
	});

}
function data_woman(){
$.getJSON("../data/data_woman.php",function(data){

	//show data news
if(data["numhead"] > 0){
     $.each(data["d_head"],function(i,v){
     
            $("#box_head_article").html('<div id=c_imge>'+v['c_image']+'</div><div id =title_news><span id=c_title>'+v['c_title']+'</span>'+
			    '<span id =c_intro>'+v['c_intro']+'</span></div>');

      
	});
 }
 
	//show data article
if(data["numarticle"] > 0){
     $.each(data["d_article"],function(i,v){
       
            $("#box_side_article").append('<div id = "box_side">'+v['c_img']+'</div><div id="box_c_title1">'+
			    '<span class="c_title1">'+v['c_title1']+'...</span></div>');
		
        
	});
 }
 
	//show data lifestyle
if(data["numlife"] > 0){
    $.each(data["d_l"],function(i,v){
        if (i >0){
            $("#data_life_other").append('<ul class="title_l"><li class="li_title"><span class="font_life">'+
				'<a href="/detail_article.php?c_id='+v['c_id']+'" target="_blank" title="'+v['c_title']+'">'+v['c_title']+'</a></span></li></ul>');
        }else{
            $("#data_life_style").html('<div class="data_life"><span class="img_life">'+
				'<a href="/detail_article.php?c_id='+v['c_id']+'" target="_blank" title="'+v['c_title']+'">'+
				'<img src='+v['c_image']+' width="100" height="68" border="0"></a></span></div><div class="text_life"><span class="title_life">'+
				'<a href="/detail_article.php?c_id='+v['c_id']+'" target="_blank" title="'+v['c_title']+'">'+v['c_title']+'</a></span><br>'+
				'<span>'+v['c_intro']+'...</span></div>');	
}
	});
	}

//show data woman&fashion
  if(data["numfashion"] > 0){
	 $.each(data["d_f"],function(i,v){
		 
var c_category = v['c_category'];
var c_parent = v['c_parent'];
 if(i > 2){

            $("#box_fashion_other").append('<ul class= title_fashion><li class=li_fashion><span class=font_fa>'+
			    '<a href="/detail_article.php?c_id='+v['c_id']+'" target="_blank" title="'+v['c_title']+'">'+v['c_title']+'</a></span></li></ul>');
 }	 
  else{     
            $("#box_W_F").append('<div class="data_healty"><span class="img_healty">'+
			    '<a href="/detail_article.php?c_id='+v['c_id']+'" target="_blank" title="'+v['c_title']+'">'+
                '<img src='+v["c_image"]+' width="100" height="68" border="0"></a></span><span class="title_text">'+
		        '<a href="/detail_article.php?c_id='+v['c_id']+'" target="_blank" title="'+v['c_title']+'">'+v["c_title"]+'</a></span></div>'); 
	

 }
	});
  }
 
//show data healty&beauty
  if(data["numhealty"] > 0){
	 $.each(data["d_h"],function(i,v){
        $("#box_H_B").append('<div class="data_healty"><span class="img_healty">'+
			'<a href="/detail_article.php?c_id='+v['c_id']+'" target="_blank" title="'+v['c_title']+'">'+
			'<img src='+v["c_image"]+' width="100" height="68" border="0"></a></span><span class="title_text">'+
		    '<a href="/detail_article.php?c_id='+v['c_id']+'" target="_blank" title="'+v['c_title']+'">'+v["c_title"]+'</a></span></div>');
	 });
  }


 

//show data workingwoman
  if(data["numwork"] > 0){
     $.each(data["d_w"],function(i,v){
        if (i >0){
            $("#data_working_other").append('<ul class=title><li class="li_title"><span class=font_life>'+
				'<a href="/detail_article.php?c_id='+v['c_id']+'" target="_blank" title="'+v['c_title']+'">'+v['c_title']+'</a></span></li></ul>');
        }else{
            $("#data_working_woman").html('<div class"=data_life"><span class="img_life">'+
				'<a href="/detail_article.php?c_id='+v['c_id']+'" target="_blank" title="'+v['c_title']+'">'+
				'<img src="'+v['c_image']+'" width="100" height="68" border="0"></a></span></div><div class="text_life"><span class="title_life">'+
                '<a href="/detail_article.php?c_id='+v['c_id']+'" target="_blank" title="'+v['c_title']+'">'+v['c_title']+'</a></span>'+
				'<br><span>'+v['c_intro']+'...</span></div>');
        }
	});
  } 
//show data mother&baby
  if(data["numbaby"] > 0){
	 $.each(data["d_b"],function(i,v){
     if (i >2){
          $("#right_mother_baby").append('<div id="right_m_b"><div id="img_right">'+
			  '<a href="/detail_article.php?c_id='+v['c_id']+'" target="_blank" title="'+v['c_title']+'">'+
			  '<img src='+v["c_image"]+' width="90" height="60" border="0"></a></div><div id="text_mother"><span class="title_mother">'+
			  '<a href="/detail_article.php?c_id='+v['c_id']+'" target="_blank" title="'+v['c_title']+'">'+v['c_title']+'</a></span></div></div>');
	 }else{

 $("#data_m_b").append('<div class="data_healty"><span class="img_healty">'+
			'<a href="/detail_article.php?c_id='+v['c_id']+'" target="_blank" title="'+v['c_title']+'">'+
			'<img src='+v["c_image"]+' width="100" height="68" border="0"></a></span><span class="title_text">'+
		    '<a href="/detail_article.php?c_id='+v['c_id']+'" target="_blank" title="'+v['c_title']+'">'+v["c_title"]+'</a></span></div>');

	 }
	 });
  }
//show data magazine
  if(data["magazine"] > 0){
	  	 var temp_data ='';
	 $.each(data["d_m"],function(i,v){
       temp_data+='<div class=img_magazine><a href="/detail_news.php?c_id='+v['c_id']+'" target="_blank" title="'+v['c_title']+'">'+v["c_image"]+
		          '<br>'+v['c_title']+'</a></div>';
	 });
  }
$("#data_magazine").html(temp_data);
  setInterval(function(){ 
				var n = $(".img_magazine").length;
				var fdivw = $('.img_magazine:first').width() + 25;
				$(".img_magazine:first").animate({"margin-left": "-="+fdivw+"px"}, "slow");
			setTimeout(function(){
					$(".img_magazine:first").remove();
				}, 2000);
				if(n < 6){
						$("#data_magazine").append(temp_data); 
					}
},5000);
		
});

}
